﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using KeaoBase;
using KeaoMDS.Listener;

namespace KeaoMDS.Report
{
    public partial class YaoKongJianCeJieGuo : BaseForm
    {
        public YaoKongJianCeJieGuo()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            BindInfo();
        }

        private void YaoKongJianCeJieGuo_Load(object sender, EventArgs e)
        {
            grid_yaokong.AutoGenerateColumns = false;
            dateTimePicker1.Value = DateTime.Today;
            dateTimePicker2.Value = dateTimePicker1.Value.AddHours(23).AddMinutes(59).AddSeconds(59);

            BindInfo();
        }

        private void BindInfo()
        {
            string createCondition = KeaoUtils._DB.CreateAndCondition("jianceshijian", DataValueCommonType.日期时间, dateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss"), dateTimePicker2.Value.ToString("yyyy-MM-dd HH:mm:ss"), SearchConditionType.between);
            DataTable Dt = KeaoUtils._DB.GetDataTableByCondition("tbl_yaokongjiance",createCondition);
            grid_yaokong.DataSource = Dt;
        }

        private void grid_riqi_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
        {
            e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //复检选定数据
            if (grid_yaokong.SelectedRows.Count > 0)
            {
                YaoKongFuJian fuJian = new YaoKongFuJian(grid_yaokong.SelectedRows);
                fuJian.ShowDialog();
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //复检全部数据
            DataTable Dt = grid_yaokong.DataSource as DataTable;
            if (Dt.Rows.Count > 0)
            {
                YaoKongFuJian fuJian = new YaoKongFuJian(Dt);
                fuJian.ShowDialog();
            }
        }
    }
}
